package com.sn.flink.streaming;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

public class CollectionJava {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        List<Integer> data = new ArrayList<>();
        data.add(10);
        data.add(20);
        data.add(30);

        DataStreamSource<Integer> dataStreamSource = env.fromCollection(data);

        dataStreamSource.map(new MapFunction<Integer, Integer>() {
            @Override
            public Integer map(Integer integer) throws Exception {
                return integer++;
            }
        }).print().setParallelism(1);

        env.execute("execute collection");
    }
}
